package com.xiaolei.lib.annotation.translators;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import com.xiaolei.lib.Activity.IActivity;
import com.xiaolei.lib.Activity.bean.AnnotationWrape;
import com.xiaolei.lib.annotation.factory.TranslatorFactory;
import com.xiaolei.lib.core.ITranslator;

/**
 * @Bind的解析器
 * @author xiaolei
 */
public class BindTranslator implements ITranslator
{
	/**
	 * 當他為變量註解時，則是findViewById
	 */
	@Override
	public void execute(Field field, IActivity activity, AnnotationWrape annotation)
	{
		FindViewByIdTranslator byIdTranslator = TranslatorFactory.getTranslator(FindViewByIdTranslator.class);
		byIdTranslator.execute(field, activity, annotation);
	}

	/**
	 * 當它為方法註解時，則是setOnClickListener
	 */
	@Override
	public void execute(Method method, IActivity activity, AnnotationWrape annotation)
	{
		setOnclickTranslator sOnclickTranslator = TranslatorFactory.getTranslator(setOnclickTranslator.class);
		sOnclickTranslator.execute(method, activity, annotation);
	}

	/**
	 * 相当于 setContentView的操作
	 */
	@Override
	public void execute(Class<?> type, IActivity activity, AnnotationWrape annotation)
	{
		setContentViewTranslator sTranslator = TranslatorFactory.getTranslator(setContentViewTranslator.class);
		sTranslator.execute(type, activity, annotation);
	}

}
